package com.njcc.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.njcc.dao.PrintPriceDao;
import com.njcc.po.PrintPrice;
import com.njcc.util.DBCon;

/**
 * 实现PrintPrice打印价格的接口
 *
 */
public class PrintPriceDaoImpl implements PrintPriceDao{
	private Connection con = null;
	private ResultSet rs = null;
	
	/**
	 * 获取printprice表中的不同类型文件的打印价格,将数据存储在list中返回
	 * @return list
	 */
	@Override
	public List<PrintPrice> getPrice(){
		List<PrintPrice> list = new ArrayList<PrintPrice>();
		try {
			con = DBCon.getCon();
			String sql = "select * from tbl_price ";
			rs = con.createStatement().executeQuery(sql);
			while(rs.next()){
				PrintPrice pp = new PrintPrice();
				pp.setId(rs.getInt("id"));
				pp.setType(rs.getString("type"));
				pp.setPrice(rs.getDouble("price"));
				list.add(pp);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			DBCon.closeAll(rs, null, con);
		}
		return list;
	}

}
